package com.cn.bukeManage.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.bukeManage.service.IndentService;

@Controller
@RequestMapping("/orders")
public class IndentsController{
	
	@Resource
	private IndentService indentService;
	@RequestMapping("/showGoods")
	@ResponseBody
	public Map<String, Object>  showGoods(HttpServletRequest request, Integer indentId){
		List<Map<String,Object>> goods=null;
		Map<String, Object> resultMap = new HashMap<String, Object>();
		if(indentId != null){
			goods=indentService.showGoods(request, indentId);
			if(goods !=null && goods.size()>0)
			resultMap.put("rows", goods);
		}
		return resultMap;
	}
	
	//鐐瑰嚮娴嬮噺璁㈠崟璺宠浆椤甸潰
		@RequestMapping("/toCeIndent")
		public String toCeIndent(Model model,Integer currentPage,Integer status){
			List<Map<String,Object>> list=indentService.getIndentOfDataByTypeAndStatus(model,currentPage,0,status);
			model.addAttribute("oneMenu", "orders");
			model.addAttribute("twoMenu", "goingOrders");	
			model.addAttribute("indents",list);
			if(status==0){
				return "orders/indentOfCeLiang";
			}else if(status==1){
				return "orders/indentOfCeLiang2";
			}else{
				return "orders/indentOfCeLiang3";
			}
		}
		//鐐瑰嚮瀹夎璁㈠崟璺宠浆椤甸潰
		//鐐瑰嚮瀹夎璁㈠崟
		@RequestMapping("/toIndentOfInstall")
		public String toIndentOfInstall(Model model,Integer currentPage,Integer status){
			List<Map<String,Object>> list=indentService.getIndentOfDataByTypeAndStatus(model,currentPage,1,status);
			model.addAttribute("oneMenu", "orders");
			model.addAttribute("twoMenu", "indentOfInstall");	
			model.addAttribute("indents",list);	
			if(status==0){
				return "orders/indentOfInstall";
			}else if(status==1){
				return "orders/indentOfInstall2";
			}else{
				return "orders/indentOfInstall3";
			}
		}	

}
